package com.wejoy.video.middle.station.admin.app;


import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

/**
 * 定时任务配置
 * @author admin
 */
@Configuration
public class SchedulerConfiguration implements SchedulingConfigurer {
    @Override
    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
        taskRegistrar.setScheduler(taskExecutor());
    }

    /**
     * 创建线程池
     * @return
     */
    public ScheduledExecutorService taskExecutor() {
        return Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors() + 1);
    }
}
